/*************************************************************************
	> File Name: B3939.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-01-17 16:21:17
 ************************************************************************/

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int is_prime(int n) {
    if (n == 1) return 0;
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0) return 0;
    }
    return 1;
}

int is_val(int n) {
    int x = n % 10 * 10 + n / 10;
    return is_prime(n) && is_prime(x);
}

int main() {
    int a, b;
    cin >> a >> b;
    for (int i = a; i <= b; i++) {
        if (!is_val(i)) continue;
        cout << i << endl;
    }
    return 0;
}
